<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLoginLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('login_logs', function (Blueprint $table) {

            $table->increments('id');

            $table->unsignedInteger('user_id')->comment('用户ID');

            $table->string('user_type', 100)->comment('用户类型');

            $table->boolean('remember')->default(false)->comment('是否记住登录状态');

            $table->unsignedInteger('ip')->nullable()->comment('登录IP');

            $table->string('ua')->nullable()->comment('UserAgent');

            $table->timestamp('created_at')->comment('登录时间');

            $table->index(['user_id', 'user_type']);

            $table->comment = '登录日志';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('login_logs');
    }
}
